function I=anisoimgaussian2(I, sigma, delta_x, delta_y)
% Anisoimgaussian2 filters 2D image with a gaussian filter.
% This function uses IMFILTER, for the filtering but instead of using
% a multidimensional gaussian kernel, it uses the fact that a gaussian
% filter can be separated in 1D gaussian kernels.
%
% inputs,
%   I: 2D input image
%   sigma: The sigma used for the gaussian
%   delta_x, delta_y: voxel size
% 
% outputs,
%   J: The gaussian filterd image
%

% Gaussian kernels
Hx = Gaussian1D_Kernel(delta_x, sigma);
Hy = Gaussian1D_Kernel(delta_y, sigma);

% Filter each dimension with the 1D gaussian kernels
H_x=reshape(Hx,[length(Hx) 1]);
H_y=reshape(Hy,[1 length(Hy)]); 
iptsetpref('UseIPPL', false)
I=imfilter(imfilter(I,H_x,'replicate'),H_y,'replicate');

        
